<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>用户组</title>
<link rel="shortcut icon" href="$request.getContextPath()/resources/cws/images/logo.ico" /> 
<link rel="stylesheet" type="text/css" href="$request.getContextPath()/resources/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="$request.getContextPath()/resources/layui/css/layui.css">
<link rel="stylesheet" href="$request.getContextPath()/resources/bootstrap-table/css/bootstrap-table.min.css" >
<style type="text/css">
body,.container-fluid{
  padding: 0px;
  margin: 0px;
  width:99.5%;
  height:100%;
}
.container-fluid .content{
  padding: 0px;
  margin: 0px;
  width:100%;
  height:100%;
}
.container-fluid .content .bootstrap-table{
  padding: 0px;
  margin: 0px;
  width:100%;
  height:100%;
}
</style>
</head>
<body>
  <div class="container-fluid">
	 <div class="content">
	    <div id="toolbar">
			#if($shiro.hasPermission('system:group:add'))
			    <button type="button" class="btn btn-default btn-sm" onclick="addGroup()"><span class="glyphicon glyphicon-plus"></span>添加</button>
			#end
			<!--<button type="button" class="btn btn-default btn-sm" onclick="addGroup()"><span class="glyphicon glyphicon-plus"></span>导入</button>-->
			#if($shiro.hasPermission('system:group:export'))
				#if($model.has('sys_group'))
					<a type="button" class="btn btn-default btn-sm" href="$request.getContextPath()/common/export/excel/sys_group/xlsx"><span class="glyphicon glyphicon-export"></span>导出</a>
				#end
			#end
	    </div>
	    <table id="table"
	           data-toggle="table"
	           data-toolbar="#toolbar" 
	           data-show-refresh="true"
	           data-search="true"
               data-show-toggle="true"
               data-show-columns="true"
               data-show-export="true"
	           data-show-export="true"
           	   data-pagination="true"
           	   data-query-params="queryParams"
           	   data-query-type="limit"
           	   data-show-footer="false"
           	   data-click-to-select="true"
           	   data-single-select="false"
           	   data-striped="true"
           	   data-method="get"
           	   data-url="$request.getContextPath()/system/group/page"
           	   data-side-pagination="server"
	           data-page-list="[10, 25, 50, 100, ALL]" 
	           data-show-pagination-switch="true"
           	   data-search-on-enter-key="true"
           	   data-pagination-v-align="bottom"
	           data-show-pagination-switch="true">
	        <thead>
			  <tr>
			     <!--<th data-checkbox="true" data-width="40px"></th>-->
                 <th data-field="groupId">组ID</th>
                 <th data-field="groupName">组名称</th>
                 <th data-field="orgId" data-visible="false">机构ID</th>
				  <th data-field="orgName">机构名称</th>
                 <th data-field="createTime">创建时间</th>
                 <th data-field="remark">组织描述</th>
                 <th data-field="operate" data-formatter="operateFormatter" data-events="operateEvents">操作</th>
			  </tr>
			</thead>
	     </table>
	 </div>
  </div>
</body>
<script type="text/javascript" src="$request.getContextPath()/resources/jquery/jquery-3.1.0.min.js"></script>
<script type="text/javascript" src="$request.getContextPath()/resources/bootstrap/js/bootstrap.min.js"></script>

<script type="text/javascript" src="$request.getContextPath()/resources/layer/layer.js"></script>
<script type="text/javascript" src="$request.getContextPath()/resources/layui/layui.js"></script>
<script type="text/javascript" src="$request.getContextPath()/resources/layui/lay/modules/element.js"></script>

<script type="text/javascript" src="$request.getContextPath()/resources/bootstrap-table/js/bootstrap-table.min.js"></script>
<script type="text/javascript" src="$request.getContextPath()/resources/bootstrap-table/js/bootstrap-table-zh-CN.min.js"></script>
<script type="text/javascript">
//组织机构图
function addGroup(){
	top.window.layer.open({
		 type: 2, 
		 title :'添加用户组',
		 maxmin: true,
		 content: ['$request.getContextPath()/system/group/add','yes'],
		 area: ['800px', '600px'],
		 end:function(){
			 queryGroup();
		 }
	});
}
//表格查询参数
function queryParams(params) {
    return {
    	orgId:null,
    	groupName:params.search,
    	beginIndex:params.offset,
    	pageSize:params.limit
    };
}
//查询用户组
function queryGroup(){
	var $table = $('#table');    
	$table.bootstrapTable("refresh");
}
//操作按钮
function operateFormatter(value, row, index) {
	var buttons=[];
	var viewGroupPermission="$shiro.hasPermission('system:group:view')";
	if(viewGroupPermission&&viewGroupPermission=="true"){
		buttons.push('<button type="button" class="btn btn-default btn-sm groupDetail"><span class="glyphicon glyphicon-eye-open"></span>查看</button>');
	}
	var editGroupPermission="$shiro.hasPermission('system:group:edit')";
	if(editGroupPermission&&editGroupPermission=="true"){
		buttons.push('<button type="button" class="btn btn-default btn-sm editGroup"><span class="glyphicon glyphicon-edit"></span>编辑</button>');
	}
	var deleteGroupPermission="$shiro.hasPermission('system:group:delete')";
	if(deleteGroupPermission&&deleteGroupPermission=="true"){
		buttons.push('<button type="button" class="btn btn-default btn-sm deleteGroup"><span class="glyphicon glyphicon-trash"></span>删除</button>');
	}
	var allowRoleGroupPermission="$shiro.hasPermission('system:group:alloRole')";
	if(allowRoleGroupPermission&&allowRoleGroupPermission=="true"){
		buttons.push('<button type="button" class="btn btn-default btn-sm alloRole"><span class="glyphicon glyphicon-trash"></span>分配角色</button>');
	}
	var membersGroupPermission="$shiro.hasPermission('system:group:memberAdd')";
	if(membersGroupPermission&&membersGroupPermission=="true"){
		buttons.push('<button type="button" class="btn btn-default btn-sm members"><span class="glyphicon glyphicon-trash"></span>组员</button>');
	}
    return buttons.join('');
}
//表格点击事件
var operateEvents = {
        //机构组织详情
		'click .groupDetail': function (e, value, row, index) {
			top.window.layer.open({
				 type: 2, 
				 title :'查看用户组详情',
				 maxmin: true,
				 content: ['$request.getContextPath()/system/group/view/'+row.groupId,'yes'],
				 area: ['800px', '600px']
			});
        },
        //编辑机构组织
        'click .editGroup': function (e, value, row, index) {
        	top.window.layer.open({
				 type: 2, 
				 title :'编辑用户组',
				 maxmin: true,
				 content: ['$request.getContextPath()/system/group/edit/'+row.groupId,'yes'],
				 area: ['800px', '600px'],
				 end:function(){
					 queryGroup();
				 }
			});
        },
        //删除机构组织
        'click .deleteGroup': function (e, value, row, index) {
        	layer.confirm('你确定要删除用户组【'+row.groupName+'】吗?', {icon: 3, title:'提示'}, function(index){
        		$.post("$request.getContextPath()/system/group/delete/"+row.groupId,{_method:'delete'},function(data){
        			if(data.code==200){
        				top.layer.msg(data.msg,{
            				icon: 1,
            				skin: 'demo-class',
            				title :'信息',
            				time:2000,
            			    area: ['300px', '160px'],
            			    offset: 'rb',
            			    end :function(){
            			    	queryGroup();
            			    	layer.close(index);
            			    }
            			});
        			}else{
        				layer.alert(data.msg);
        			}
        		});
        	});
        },
        //删除机构组织
        'click .alloRole': function (e, value, row, index) {
        	top.window.layer.open({
				 type: 2, 
				 title :'用户组分配角色',
				 maxmin: true,
				 content: ['$request.getContextPath()/system/group/allowRole?groupId='+row.groupId,'yes'],
				 area: ['600px', '400px']
			});
        },
        //获取该用户组下的用户集合
        'click .members': function (e, value, row, index) {
        	top.window.layer.open({
				 type: 2, 
				 title :'用户组分配角色',
				 maxmin: true,
				 content: ['$request.getContextPath()/system/group/members?groupId='+row.groupId,'yes'],
				 area: ['800px', '600px']
			});
        }
};
$(function(){
	msg('用户组织信息加载完毕');
});
</script>
</html>
#parse("/portal/account/footer2.html")